<template>
  <div class="gallery" @click="handleGalleryClick">
    <div class="gallery-wrapper">
      <swiper :options="swiperOption" >
        <swiper-slide v-for="(item, index) of imgs" :key="index">
          <img class="gallery-img" :src="item">
        </swiper-slide>
        <div class="swiper-pagination"  slot="pagination"></div>
      </swiper>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Gallery',
  props: {
    imgs: {
      type: Array,
      default () {
        return []
      }
    }
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        paginationType: 'fraction',
        loop: true,
        observeParents: true,
        observer: true
      }
    }
  },
  methods: {
    handleGalleryClick () {
      this.$emit('chege')
    }
  }
}
</script>

<style lang="stylus" scoped>
  .gallery >>> .swiper-container
    overflow: inherit
  .gallery
    position: fixed
    display: flex
    flex-direction: column
    justify-content: center
    z-index: 99
    top: 0
    left: 0
    right: 0
    bottom: 0
    background: #000
    .gallery-wrapper
      height: 0
      padding-bottom: 70%
      width: 100%
      .gallery-img
        width: 100%
        height: 100%;
    .swiper-pagination
      color: #fff
      bottom: -1.5rem
</style>
